<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app">
        {{fullName}}
    </div>
    <script>
        var app=new Vue({
            el:'#app',
            data:{
                firstName:'Dell',
                lastName:'Lee',  
                /*3.监听器要添加 fullName:'Dell Lee' */             
            },
        //1.计算属性,有缓存，相关属性不改变则不会再次运行
            computed:{
                fullName:{              
                    get:function(){
                        return this.firstName+" "+this.lastName;
                    },
                    set:function(value){
                        var arr=value.split(" ");//打散
                        this.firstName=arr[0];
                        this.lastName=arr[1];
                    }
                }
            }
        
         //2.方法
            /*methods:{
                 fullName:function(){
                    return this.firstName+" "+this.lastName;
                } 通过{{fullName()}}来调用，没有缓存页面任何东西改变都会导致这个方法再次运行
            },*/
        //3.监听器
            /* watch:{//有缓存
                firstName:function(){
                    this,fullName=this.firstName+" "+this.lastName;
                },
                lastName:function(){
                    this,fullName=this.firstName+" "+this.lastName;
                }
            }, */
        })
    </script>
</body>
</html>